GBML manual / Drawing

sprite_origin_y

The y pixel of a sprite asset’s own origin, measured from its top-left (of a single animation frame — a multi-frame sheet’s origin applies to every frame alike). Same rule as sprite_origin_x: unset answers the sprite’s own center.

Sega Genesis: not built yet

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

sprite_origin_y(spr) -> int

Arguments

NameType
sprsprite

Returns

int

Description

The y pixel of a sprite asset's own origin, measured from its top-left (of a single animation frame - a multi-frame sheet's origin applies to every frame alike, since every frame shares one shape). Same rule as sprite_origin_x: an unauthored sprite answers its own center (sprite_height(spr) / 2), so a sprite nobody has given an origin draws exactly where it always did.

Origins are usually set once, visually, in the Sprites tab, and then simply work: default drawing and every draw_sprite* call already place a sprite by this point, not its center. This query is for reading the raw number back - for example to reach past the origin to a fixed part of the art itself.

Example

shadow_y = y + (sprite_height(spr_doc_hero) - sprite_origin_y(spr_doc_hero));

The y position of this sprite's own lowest drawn pixel, whatever its origin is set to (its center, for a sprite that also needs to rotate cleanly, say) - a shadow drawn here sits under the art itself, not under wherever the origin happens to be.

On the GBA

Same runtime cost as sprite_origin_x — see its own gba note.

See also: sprite_origin_xsprite_widthsprite_height